package com.jy.wms.common.quartz;

import org.quartz.*;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 各个job参数设置
 * @author liyi
 */
@Component
public class MyScheduler {

    @Resource
    private SchedulerFactoryBean schedulerFactoryBean;
  /*  public  SchedulerFactoryBean getSchedulerFactoryBean() {
        return new SchedulerFactoryBean();
    }*/

   @Resource
    private CronTrigger cronTrigger;
    @Resource
    private JobDetail jobDetail;
    @Resource
    private CronTrigger StockcronTrigger;
    @Resource
    private JobDetail StockjobDetail;
    /*@Resource
    private CronTrigger ProvinceTrigger;
    @Resource
    private JobDetail JobDetail;*/
    @Resource
    private CronTrigger ProductTrigger;
    @Resource
    private JobDetail ProductJobDetail;
    @Resource
    private CronTrigger VelocityTrigger;
    @Resource
    private JobDetail VelocityJobDetail;
    @Resource
    private CronTrigger PickTrigger;
    @Resource
    private JobDetail PickJobDetail;
    @Resource
    private CronTrigger StoreHouseTrigger;
    @Resource
    private JobDetail StoreHouseJobDetail;

    public void scheduleJobs() throws SchedulerException {
        schedulerFactoryBean.getScheduler().scheduleJob(jobDetail, cronTrigger);
        schedulerFactoryBean.getScheduler().scheduleJob(StockjobDetail, StockcronTrigger);
        //schedulerFactoryBean.getScheduler().scheduleJob(JobDetail, ProvinceTrigger);
        schedulerFactoryBean.getScheduler().scheduleJob(ProductJobDetail, ProductTrigger);
        schedulerFactoryBean.getScheduler().scheduleJob(VelocityJobDetail, VelocityTrigger);
        schedulerFactoryBean.getScheduler().scheduleJob(PickJobDetail, PickTrigger);
        schedulerFactoryBean.getScheduler().scheduleJob(StoreHouseJobDetail, StoreHouseTrigger);
    }



///    private void startJob2(Scheduler scheduler) throws SchedulerException{
//        JobDetail jobDetail = JobBuilder.newJob(ScheduledJob2.class) .withIdentity("job2", "group1").build();
//        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("0/10 * * * * ?");
//        CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity("trigger2", "group1") .withSchedule(scheduleBuilder).build();
//        scheduler.scheduleJob(jobDetail,cronTrigger);
//    }
}